<?php
/**
 * Created by Jayli.
 * User: Administrator
 * Date: 2018-03-07
 * Time: 14:46
 */

namespace App\Http\Controllers\Web\Member\Seller;

use App\Http\Controllers\Web\BaseController;
use Illuminate\Http\Request;

class OrderProductsController extends BaseController
{
    protected $api_url = [
        'update' => ['put', 'seller/orders/%d/order_products'],
        'order_show' => ['get', 'seller/orders/%d'],
    ];

    protected $request;

    public function __construct(Request $request)
    {
        $this->request = $request;
    }

    public function edit($order_id)
    {
        $params = [
            'with' => 'orderProducts'
        ];
        //请求部分
        $ret = http_web($this->api_url['order_show'], [$order_id])->send($params);

        return view('web.user.seller.common.modify_product_price', ['order' => $ret['data']]);
    }

    public function update($order_id)
    {
        $params = [
            'change_data' => $this->request->get('order_products', [])
        ];

        //请求部分
        $ret = http_web($this->api_url['update'], [$order_id])->send($params);

        return $ret;
    }
}